package com.asynchfileupload.view;

import java.security.SecureRandom;
import java.math.BigInteger;

/**  
* FileUploadSession.java - This class generates a new files session on every file upload request.  
* @author  Avinash Singh (349933)
* @version 1.0 
*/
public final class FileUploadSession {

	private SecureRandom random;
	private String sessionID;
	private String instanceID;
	private String groupID;
	private String fileName;
	private String errorMessage;
	boolean fileUploadStatus = false;
	int statusIndicator = -1;
	
	public FileUploadSession(String instanceID, String groupID) {
		this();
		this.instanceID = instanceID;
		this.groupID = groupID;
	}

	public FileUploadSession() {
		random = new SecureRandom();
		sessionID = nextSessionId();
	}

	private String nextSessionId() {
		return new BigInteger(130, random).toString(32);
	}

	public SecureRandom getRandom() {
		return random;
	}

	public void setRandom(SecureRandom random) {
		this.random = random;
	}

	public String getSessionID() {
		return sessionID;
	}

	public void setSessionID(String sessionID) {
		this.sessionID = sessionID;
	}

	public String getInstanceID() {
		return instanceID;
	}

	public void setInstanceID(String instanceID) {
		this.instanceID = instanceID;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public String getGroupID() {
		return groupID;
	}

	public void setGroupID(String groupID) {
		this.groupID = groupID;
	}

	public boolean isFileUploadStatus() {
		return fileUploadStatus;
	}

	public void setFileUploadStatus(boolean fileUploadStatus) {
		this.fileUploadStatus = fileUploadStatus;
	}

	public int getStatusIndicator() {
		return statusIndicator;
	}

	public void setStatusIndicator(int statusIndicator) {
		this.statusIndicator = statusIndicator;
	}

	public String getErrorMessage() {
		return errorMessage;
	}

	public void setErrorMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}

}
